feat(http-specs): add SSE protocol Spector scenarios - #11613
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: ee116a23-26c2-4be5-b305-6c2733ad0790
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: ee116a23-26c2-4be5-b305-6c2733ad0790
|
All changed packages have been documented.
Show changes
|
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: ee116a23-26c2-4be5-b305-6c2733ad0790
commit: |
|
You can try these changes here
|
There was a problem hiding this comment.
Pull request overview
Adds new Server-Sent Events (SSE) protocol-focused Spector scenarios to the @typespec/http-specs suite to cover SSE envelope metadata behavior (event id, retry, and resumption via Last-Event-ID) and updates the generated spec summary and changelog accordingly.
Changes:
- Added new SSE “Protocol” scenarios for
id, invalidid(U+0000), valid/invalidretry, and a reconnect case requiringLast-Event-ID. - Extended the SSE mock API definitions to serve protocol-level event-stream payloads for the new scenarios.
- Updated the generated
spec-summary.mdand added a Chronus changelog entry for@typespec/http-specs.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/http-specs/specs/streaming/sse/mockapi.ts | Adds mock responses for new SSE protocol scenarios (id/retry/reconnect) using text/event-stream payloads. |
| packages/http-specs/specs/streaming/sse/main.tsp | Defines new Protocol namespace scenarios documenting expected SSE protocol behavior for id/retry/reconnect. |
| packages/http-specs/spec-summary.md | Includes generated documentation entries for the new scenarios/endpoints. |
| .chronus/changes/iscai-msft-add-sse-spector-scenarios-2026-7-10-14-23-58.md | Changelog entry for the new @typespec/http-specs SSE protocol coverage. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
.chronus/changes/iscai-msft-add-sse-spector-scenarios-2026-7-10-14-23-58.md:7
- This entry is marked as
changeKind: feature, and other feature entries in this repo typically include a short illustrative code block (oftentsp) showing the new scenario/API surface (e.g..chronus/changes/add-body-or-no-content-scenario-2026-8-14.md:9-16). Consider adding a smalltspsnippet demonstrating one of the new SSE protocol scenarios so the changelog entry matches the established format for features.
Add SSE protocol coverage for event IDs, retry fields, and reconnection
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: b5f920be-9f18-40f9-af98-d8d3bae093df
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: b5f920be-9f18-40f9-af98-d8d3bae093df
This reverts commit b2774d3.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: b5f920be-9f18-40f9-af98-d8d3bae093df
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
packages/http-specs/specs/streaming/sse/mockapi.ts:216
- The reconnect mock relies on a closure-scoped
reconnectedflag to decide whether to enforce thelast-event-idheader. Because this handler instance is shared across the whole Spector server lifetime, the behavior becomes non-idempotent (e.g., reruns or concurrent requests can flip the flag and cause unexpected 400s). Prefer making the response selection deterministic from the request itself (e.g., treat presence oflast-event-idas the reconnect call, validate it when present, otherwise return the initial response) so the mock is repeatable and robust.
reconnected = true;
return {
pass: "initial",
status: 200,
body: {
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: b5f920be-9f18-40f9-af98-d8d3bae093df
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Suppressed comments (3)
Previously missed (3) — in code that hasn't changed since the last review.
packages/http-specs/specs/streaming/sse/main.tsp:272
- The reconnect scenario documentation says the first response closes after sending
event-1, but the "Expected response body" section only shows the reconnect response (event-2). Since the mock sends an initialevent-1response before the reconnect, consider documenting both responses (initial + reconnect) or clearly labeling the snippet as "Expected response body on reconnect" to avoid ambiguity.
@scenarioDoc("""
An SSE stream that resumes after a reconnect. The first response closes after
sending `event-1`. On reconnect, the client sends the most recently received
event ID in the `Last-Event-ID` request header.
packages/http-specs/specs/streaming/sse/main.tsp:207
- There are whitespace-only lines inside the new
@scenarioDocblocks (e.g. the blank line after "not part of the typed event data."). These show up as trailing whitespace in diffs/linters and can causegit diff --checkor format checks to fail. Remove the trailing spaces (make the line truly empty) or re-run the formatter on this file.
@scenarioDoc("""
An SSE event with an `id` field. The event ID is envelope metadata and is
not part of the typed event data.
Expected response body (content type `text/event-stream`):
packages/http-specs/spec-summary.md:5470
- This scenario description reads like a two-step flow (initial stream returns
event-1, then reconnect returnsevent-2withLast-Event-ID), but the "Expected response body" block only shows the reconnect response. Consider documenting both the initial and reconnect response bodies (or label this as the reconnect-only response) so readers understand what the client receives before it can sendLast-Event-ID.
An SSE stream that resumes after a reconnect. The first response closes after
sending `event-1`. On reconnect, the client sends the most recently received
event ID in the `Last-Event-ID` request header.
Expected request header on reconnect:
Last-Event-ID: event-1
Expected response body (content type `text/event-stream`):
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: b5f920be-9f18-40f9-af98-d8d3bae093df
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: b5f920be-9f18-40f9-af98-d8d3bae093df
fixes #11572
Summary
Validation